home *** CD-ROM | disk | FTP | other *** search
/ Aminet 24 / Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso / Aminet / dev / c / AmiVoGL_MDEV.lha / drivers / ibmpc / ega.c < prev    next >
C/C++ Source or Header  |  1991-09-29  |  2KB  |  123 lines

  1. #include    "vogl.h"
  2.  
  3. #define    E_PIX_ASPECT    1.3
  4.  
  5. static    int    old_mode;
  6. extern    unsigned    int    _buffer_segment;
  7. extern    unsigned    int    _buffer_offset;
  8.  
  9. extern    int
  10.         vega_backbuf(),
  11.         vega_char(),
  12.         vega_clear(),
  13.         vega_color(),
  14.         vega_draw(),
  15.         vega_setpal(),
  16.         pc_fill(),
  17.         vega_font(),
  18.         vega_frontbuf(),
  19.         pc_getkey(),
  20.         pc_checkkey(),
  21.         pc_locator(),
  22.         vega_string(),
  23.         vega_swapbuf(),
  24.         setmode();
  25.  
  26. static int
  27. ega_init()
  28. {
  29.     old_mode = setmode(16);
  30.     vdevice.sizeX = 349 * E_PIX_ASPECT;
  31.     vdevice.sizeY = 349;
  32.     vdevice.sizeSx = 639;
  33.     vdevice.sizeSy = 349;
  34.     vdevice.depth = 4;
  35.     _buffer_segment = (unsigned) 0xA000;
  36.     _buffer_offset = 0;
  37.     pc_locinit(vdevice.sizeSx, vdevice.sizeSy);
  38.     zsetup();
  39.     vega_setpal();
  40.     return (1);
  41. }
  42.  
  43. /* 
  44.  * ega_vclear
  45.  *
  46.  *    Just clears the current viewport.
  47.  */
  48. static
  49. ega_vclear()
  50. {
  51.     int     x[4], y[4];
  52.  
  53.     if (vdevice.maxVx != vdevice.sizeSx
  54.         || vdevice.maxVy != vdevice.sizeSy
  55.         || vdevice.minVx != vdevice.sizeSx
  56.         || vdevice.minVy != vdevice.sizeSy) {
  57.         x[0] = x[3] = vdevice.minVx;
  58.         y[0] = y[1] = vdevice.maxVy;
  59.         y[2] = y[3] = vdevice.minVy;
  60.         x[1] = x[2] = vdevice.maxVx;
  61.  
  62.         pc_fill(5, x, y);
  63.     } else {
  64.         vega_clear();
  65.     }
  66.  
  67.     return(0);
  68. }
  69.  
  70.  
  71. /*
  72.  * ega_exit
  73.  *
  74.  *    Sets the display back to text mode.
  75.  */
  76. static
  77. ega_exit()
  78. {
  79.     (void)setmode(old_mode);
  80.     return (1);
  81. }
  82.  
  83. static    int
  84. noop()
  85. {
  86.     return (-1);
  87. }
  88.  
  89. static DevEntry egadev = {
  90.     "ega",
  91.     "large",
  92.     "small",
  93.     vega_backbuf,
  94.     vega_char,
  95.     pc_checkkey,
  96.     ega_vclear,
  97.     vega_color,
  98.     vega_draw,
  99.     ega_exit,
  100.     pc_fill,
  101.     vega_font,
  102.     vega_frontbuf,
  103.     pc_getkey,
  104.     ega_init,
  105.     pc_locator,
  106.     noop,
  107.     vega_string,
  108.     vega_swapbuf
  109. };
  110.  
  111. /*
  112.  * _ega_devcpy
  113.  *
  114.  *    copy the pc device into vdevice.dev.
  115.  */
  116. _ega_devcpy()
  117. {
  118.     vdevice.dev = egadev;
  119.  
  120.     return(0);
  121. }
  122.  
  123.